package com.blue.firecat.controller;

import com.alibaba.fastjson.JSON;
import com.blue.firecat.contants.Contants;
import com.blue.firecat.contants.Result;
import com.blue.firecat.entity.Order;
import com.blue.firecat.serivce.OrderService;
import com.blue.firecat.utils.controller.BaseController;
import com.blue.firecat.vo.OrderVo;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * @描述
 * @时间 2017-6-27 16:49
 * @作者 肖亦鸣
 */
@Controller
@RequestMapping("v")
public class VisitorController extends BaseController {

    private static Logger logger = LogManager.getLogger(VisitorController.class.getName());

    @Autowired
    OrderService orderService;

    @RequestMapping("getOrder")
    public String getOrder(Long orderId) {
        logger.info("orderId:{}", orderId);
        request.setAttribute(Contants.MESSAGE, orderId);
        if (orderId == null) {
            return "visitor";
        }
        Result<Order> result = orderService.selectByPrimaryKey(orderId);
        request.setAttribute(Contants.OBJECT, result.getData());
        logger.info("result:{}", JSON.toJSONString(result));
        return "visitor";
    }

    @RequestMapping("v")
    public String v() {
        return "visitor";
    }

    @RequestMapping("/")
    public String v1() {
        return "visitor";
    }
}
